$: << File.join(File.dirname(__FILE__), '..', 'lib')
require 'ann'

puts "-> create new neural network."
nn = Ann::Network.new(2, 4, 1)

puts "-> training data load."
td = [[[-1,-1],[-1]],[[-1,1],[1]],[[1,-1],[1]],[[1,1],[-1]]]

puts "-> training neural network."
nn.train(td, 30000, 10, 0.00001){|epoch, error|
  puts "#{epoch} #{error}"
}

puts "-> test neural network."
nn.clear
nn.load_input([0, 0])
puts "#{nn.layers.last[0].output} should be -1"
nn.clear
nn.load_input([0, 1])
puts "#{nn.layers.last[0].output} should be 1"
nn.clear
nn.load_input([1, 0])
puts "#{nn.layers.last[0].output} should be 1"
nn.clear
nn.load_input([1, 1])
puts "#{nn.layers.last[0].output} should be -1"
